package com.promis.widget.mediapicker;

import android.content.Context;
import android.content.Intent;

import com.promis.widget.mediapicker.entity.ImageParcelable;
import com.promis.widget.mediapicker.manager.ImagePickerListener;
import com.promis.widget.mediapicker.manager.ImagePickerManager;
import com.promis.widget.mediapicker.ui.ImagePickerActivity;

import java.util.List;

/**
 * Created by jidanbo on 2018/3/26.
 */

public class ImagePickerApi {

    public static Builder with(Context context) {
        Builder builder = new Builder(context);
        return builder;
    }

    public static class Builder {

        private Context context;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder maxFileCount(int maxFileCount) {
            ImagePickerManager.getInstance().setMaxFileCount(maxFileCount);
            return this;
        }

        public Builder maxFileSize(int maxFileSize) {
            ImagePickerManager.getInstance().setMaxFileSize(maxFileSize);
            return this;
        }

        public Builder filter(List<ImageParcelable> imageList) {
            ImagePickerManager.getInstance().setFilterImageList(imageList);
            return this;
        }

        public Builder subscribe(ImagePickerListener listener) {
            ImagePickerManager.getInstance().setImagePickerListener(listener);
            return this;
        }

        public void open() {
            Intent intent = new Intent(this.context, ImagePickerActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            this.context.startActivity(intent);
        }
    }
}
